/**
 * Created by jt on 2017/5/8.
 */
import "./index.less";
// import "../../../unit/common/js/common/main_portal.js";


var projId = getArgs().id;
jQuery.ajax({
    url: HOST_ADDR + '/cpmp/bidProjOnMngForPortal/viewProjDtl/' + projId,
    type: 'get',
    dataType: 'json',
    contentType: "application/json",
    success: function (resp) {
        if (!resp.success) {
            alert(resp.msgCod + ' ' + resp.msgInf);
            return;
        }
        var matTyp = resp.data.bidProjOn.matTyp;
        if(resp.data.matTypDesc!=null && resp.data.matTypDesc!=''){
            matTyp = resp.data.matTypDesc;
        }
        viewProjRstDtl(matTyp);
    },
    error: function (err) {
        alert('系统错误！');
    }
});


function viewProjRstDtl(matTyp){
    jQuery.ajax({
        url: HOST_ADDR+'/cpmp/bidProjOnMngForPortal/viewProjRstDtl/'+projId,
        type: 'get',
        dataType: 'json',
        contentType:"application/json",
        success: function(resp){
            if (!resp.success) {
                alert(resp.msgCod+' '+resp.msgInf);
                return;
            }
            var projqotCntTyp;
            if (resp.data.qotCntTyp == 0) {
                projqotCntTyp='一次报价';
            } else if (resp.data.qotCntTyp == 1) {
                projqotCntTyp='多次报价';
            } else if (resp.data.qotCntTyp == 2) {
                projqotCntTyp='实时报价';
            } else {
                projqotCntTyp='';
            }
            var bidRngTyp;
            var splrs=[];
            if (resp.data.bidRngTyp == 0) {
                bidRngTyp='非定向招标';
                splrs='';
            } else if (resp.data.bidRngTyp == 1) {
                bidRngTyp='定向招标';
                for (var i=0;i<resp.data.splrs.length;i++) {
                    splrs.push(resp.data.splrs[i].splrNam);
                }
            } else {
                bidRngTyp='';
                splrs='';
            }

            var currTyp;
            if (resp.data.currTyp == 'USD') {
                currTyp='美元';
            } else if (resp.data.currTyp == 'RMB') {
                currTyp='人民币';
            } else {
                currTyp='';
            }
            var dpstFlg;
            if (resp.data.dpstFlg == 0) {
                dpstFlg='不需要';
            } else if (resp.data.dpstFlg == 1) {
                dpstFlg='需要';
            } else {
                dpstFlg='';
            }
            var pubPriFlg;
            if (resp.data.pubPriFlg == 0) {
                pubPriFlg='否';
            } else if (resp.data.pubPriFlg == 1) {
                pubPriFlg='是';
            } else {
                pubPriFlg='';
            }

            var rstPubTim, bidOpenTim, bidEndTim;
            if (resp.data.rstPubTim != null&&resp.data.rstPubTim !='') {
                rstPubTim = (new Date(resp.data.rstPubTim)).Format("yyyy-MM-dd hh:mm:ss");
            } else {
                rstPubTim = '';
            }
            if (resp.data.bidOpenTim != null&&resp.data.bidOpenTim !='') {
                bidOpenTim = (new Date(resp.data.bidOpenTim)).Format("yyyy-MM-dd hh:mm:ss");
            } else {
                bidOpenTim = '';
            }
            if (resp.data.bidEndTim != 'null'&&resp.data.bidEndTim !='') {
                bidEndTim = (new Date(resp.data.bidEndTim)).Format("yyyy-MM-dd hh:mm:ss");
            } else {
                bidEndTim = '';
            }
            if (resp.data.projMemo != null&&resp.data.projMemo !='') {
                var projMemo = resp.data.projMemo;
            } else {
                projMemo = '';
            }
            var projNbr;
            if (resp.data.projNbr != null &&resp.data.projNbr !='') {
                projNbr=resp.data.projNbr;
            } else {
                projNbr = '';
            }

            console.log(resp)

            jQuery('.projTitle').html(resp.data.projNam+'<div class="service-block-v5 margin-top-20">' +
                '<p class="fontsize-14">'+rstPubTim+'</p></div>');

            // var matTyp = resp.data.matTyp;
            // if(resp.data.matTypDesc!=null && resp.data.matTypDesc!=''){
            //     matTyp = resp.data.matTypDesc;
            // }

            jQuery('.basicInfo').append('<tbody><tr>' +
                '<td width="16%">项目名称：</td><td colspan="2">'+resp.data.projNam+'</td> ' +
                '<td width="16%">项目编号：</td> <td colspan="2">'+projNbr+'</td></tr><tr>' +
                '<td width="16%">物料品类：</td><td colspan="2">'+matTyp+'</td>' +
                '<td width="16%">报价次数类型：</td><td colspan="2">'+projqotCntTyp+'</td></tr> <tr>' +
                '<td width="16%">招标单位：</td><td colspan="2">'+resp.data.bidDptNam+'</td>' +
                '<td width="16%">招标单位地址：</td><td colspan="2">'+resp.data.bidDptAddr+'</td></tr><tr>' +
                '<tr><td width="16%">是否需要投标保证金：</td><td colspan="2">'+dpstFlg+'</td>'+
                '<td width="16%">是否需要公开招标价格：</td><td colspan="2">'+pubPriFlg+'</td></tr>'+
                '<tr><td width="16%">投标保证金（元）：</td><td colspan="2">'+resp.data.bidDpst+'</td>' +
                '<td width="16%">币种：</td><td colspan="2">'+currTyp+'</td></tr>'+
                '<tr><td width="16%">联系人：</td><td colspan="2">'+resp.data.ctct+'</td>' +
                '<td width="16%">联系电话：</td><td colspan="2">'+resp.data.ctctTel+'</td></tr><tr>' +
                '<td width="16%">投标开标时间：</td><td colspan="2">'+bidOpenTim+'</td>' +
                '<td width="16%">投标截止时间：</td><td colspan="2">'+bidEndTim+'</td></tr><tr>' +
                '<td>招标范围类型：</td><td colspan="2">'+bidRngTyp+'</td>' +
                '<td width="16%">指定招标供应商：</td><td colspan="2">'+splrs+'</td></tr><tr>' +
                '<td>备注信息：</td><td colspan="5">'+projMemo+'</td></tr></tbody>');

            // jQuery('.setInfo').append(resp.data.rplNtcInf);
            jQuery('.setInfo').append(resp.data.appRplMemo);
        },
        error:function(err){
            alert('系统错误！');
        }
    });
}